﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L05
{
    class Program
    {
        static void Main(string[] args)
        {

            Car A = new Car(10);
            Truck B = new Truck(10);
            B.Load = 20;
            A.Run(10);
            B.Run(10);
            Console.ReadKey();
        }

    }
    public abstract class Vehicle
    {

        public float V { get; set; }
        public Vehicle(float v)
        {
            V = v;
        }
        public virtual void Run(float d)
        {
            Console.WriteLine("行驶{0}公里用时{1}", d, d / V);
        }
    }
    public class Car : Vehicle
    {
        public float Passengers { get; set; }
        public Car(float v) : base(v) { }
    }
    public class Truck : Vehicle
    {
        public float Load { get; set; }
        public Truck(float v) : base(v) { }
        public virtual void Run(float d)
        {
            if (d == Load)
            {
                Console.WriteLine("行驶{0}公里用时{1}", d, (1 + Load / 100) * d / V);
            }
        }
    }
}


